/* AirSortReportDao.java
 *
 * Project/Product: GWBS2009
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   apep	2010-1-27	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2010
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package com.apep.jwcs.dao;

import java.util.List;

import com.hitrust.gs.bean.GSManufactureBean;
import com.hitrust.gs.bean.GSManufactureCategoryBean;
import com.hitrust.gs.bean.GSOutHeadBean;
import com.hitrust.gs.bean.GSOutSubBean;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.exception.GSException;

public class AirSortReportDao extends GSBaseDAO{
    
    public List findOutHeadByTimeAndWarehouseCode(String startTime,String endTime,String warehouseCode)throws GSException{
        String sql="select * from t_out_head where repair_bill_code is not null and" +
                " repair_bill_code <>' ' and customer_bus_code is not null and customer_bus_code <>' ' " +
                "and warehouse_code=? and out_time >? and out_time <?";
        List list=null;
        Object[] obj={warehouseCode,startTime,endTime};
        try {
            list=this.executeQuery(new GSOutHeadBean(), sql, obj);
        } catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E10040, GSException.E10040_MSG);
        }
        return list;
    }

    public List findOutSubByOutBillCode(String outBillCode)throws GSException{
        String sql="select * from t_out_sub where out_bill_code=?";
        List list=null;
        Object[] obj={outBillCode};
        try {
            list=this.executeQuery(new GSOutSubBean(), sql, obj);
        } catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E10040, GSException.E10040_MSG);
        }
        return list;
    }
    
    public GSManufactureBean findProductByType(String productCode) throws GSException{
        GSManufactureBean bean=new GSManufactureBean();
        String sql="select * from t_product where CONCENTRICITY_CODE=? ";
        Object[] obj={productCode};
        try {
            List list=this.executeQuery(new GSManufactureBean(),sql, obj);
            if(list.size()>0){
                bean= (GSManufactureBean) list.get(0);
            }
        } catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E10040, GSException.E10040_MSG);
        }
        return bean;
    }
    
    public GSManufactureCategoryBean findproductCategoryByCode(String code)throws GSException{
        GSManufactureCategoryBean bean=new GSManufactureCategoryBean();
        String sql="select * from t_product_category where code=?";
        Object[] obj={code};
        try {
            List list=this.executeQuery(new GSManufactureCategoryBean(), sql, obj);
            if(list.size()>0){
                bean=(GSManufactureCategoryBean) list.get(0);
            }
        } catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E10040, GSException.E10040_MSG);
        }
        return bean;
    }
}
